#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="client"
__date__="2016/6/29"
__time__="9:49"
"""
import socket

"""
# client demo1 接收数据
# 创建一个socket对象
client = socket.socket()
ip_port = ('127.0.0.1',9999)
# 创建连接
client.connect(ip_port)

# 接收数据
data = client.recv(1024)
print data
"""

# client demo2 客户端与服务端的交互
# 创建一个socket对象
client = socket.socket()
ip_port = ('127.0.0.1',9999)
# 创建连接
client.connect(ip_port)
while True:
    send_data_n=raw_input('input_name:')
    send_data_p=raw_input('input_pwd:')
    client.send(send_data_n)
    client.send(send_data_p)
    d = client.recv(1024)
    print d
    if 'fail' in d:
        continue
    else:
        break
while True:
    # 发送数据
    inp = raw_input('client:')
    client.send(inp)
    if inp == 'exit':
        break


    # 接收数据
    data = client.recv(1024)
    print data



